<template>
	<div class="superInviter">
		<!-- 邀请 -->
		<div class="head_box">
			<el-row>
				<el-button v-for="(item, index) in operation" :key="index" type="primary" @click="opeBtn(item.name)">{{ item.txt }}</el-button>
			</el-row>
		</div>

		<hz-form />
	</div>
</template>

<script>
import hzForm from '../components/hzForm/index.vue';
import { querySuperMemberStatus } from '@/api/business';
export default {
	components: {
		'hz-form': hzForm
	},
	data() {
		return {
			operation: [
				{
					name: 'MarketingActivitySuperInviterMerch',
					txt: '邀请商户'
				},
				{
					name: 'MarketingActivitySuperInviterMsg',
					txt: '邀请记录'
				},
				{
					name: 'MarketingActivitySuperInviterChangeMsg',
					txt: '修改记录'
				}
			],

			dataForm: '',

			dialogVisible: false
		};
	},
	mounted() {
		this.querySuperMemberStatusFun();
	},
	methods: {
		opeBtn(name) {
			if (name == 'MarketingActivitySuperInviterMerch' && this.dataForm.remainingBusinessNum == 0) {
				this.$confirm('邀请商户数已使用完，请购买后操作', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				})
					.then(() => {
						this.$router.push({
							name: 'PlugCenterAddMerc'
						});
					})
					.catch(() => {});
			} else if (name == 'MarketingActivitySuperInviterMerch' && this.dataForm.status == 2) {
				this.$confirm('插件已过期，请购买后操作', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				})
					.then(() => {
						this.$router.push({
							name: 'PlugCenterSupRenew'
						});
					})
					.catch(() => {});
			} else {
				this.$router.push({
					name
				});
			}
		},

		// 插件状态
		querySuperMemberStatusFun() {
			querySuperMemberStatus().then(res => {
				console.log('查询商户超级会员插件状态', res);
				this.dataForm = res.data;
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.head_box {
	width: 100%;
	overflow: hidden;
}
</style>
